<?php  
$file_name = $year."年".$month."月常熟领军人才入驻企业统计汇总报表"; 
if(empty($report)){?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2><?php echo $file_name;?></h2>
	</div>
    <?php
    	$url_explode=explode("group=", $_SERVER["QUERY_STRING"]);
    	echo '<div class="right back_btn">';
		echo $html->link("导出报表","/reports/totaldatareport/1?year=".$year."&month=".$month."&group=".$url_explode[1]);
		echo '</div>';
	?> 
    <div class="form_sx_drop right">
    	<?php 
		 $user=$session->read('User');
		 if($user['isadmin']||$user['isvisitor']){
			$grouplist=array_merge(array(""=>"请选择模块"),$grouplist);
	    	echo $form->select('ddlgroup',$grouplist,$group_mod_id, null,null);
			 }
    		$years=$str->getafteryear(0);
    		echo $form->select('ddlyear',$years, $year, null,null);
		    echo $form->select('ddlmonth',$months, $month, null,null);
		?>
	</div>
    <div class="clear"></div>
</div>
<?php }?>
<style>
.items_list table{
	color:black;
	font-size:12px;
	line-height:25px;
	text-align:center;
	border-collapse:collapse;
	border-style:solid;
	border-bottom:2px solid ;
}

.items_list table tr th{
	border-left:1px solid ;
	border-top:1px solid ;
	border-right:1px solid ;
	border-bottom:1px solid ;
}
.items_list table tr td{
	border-left:1px solid ;
	border-top:1px solid ;
	border-right:1px solid ;
	border-bottom:1px solid ;
}
.items_list table tr .th{
	border-left:2px solid ;
	border-top:2px solid ;
	border-right:2px solid ;
}

.items_list table tr .lth{
	border-left:2px solid ;
}

.items_list table tr .rth{
	border-right:2px solid ;
}
</style>
<?php 
	$total_prospect = $totaldatas["total"]["prospect"];
	$total_income = $totaldatas["total"]["income"];
	$total_tax = $totaldatas["total"]["tax"];
	$total_profit = $totaldatas["total"]["profit"];
	$total_patents = $totaldatas["total"]["patents"];
	$total_ht_products = $totaldatas["total"]["ht_products"];
	$total_sw_products = $totaldatas["total"]["sw_products"];
	
	$last_t_prospect = $last_totaldatas["total"]["prospect"];
	$last_t_income = $last_totaldatas["total"]["income"];
	$last_t_tax = $last_totaldatas["total"]["tax"];
	$last_t_profit = $last_totaldatas["total"]["profit"];
	$last_t_patents = $last_totaldatas["total"]["patents"];
	$last_t_ht_products = $last_totaldatas["total"]["ht_products"];
	$last_t_sw_products = $last_totaldatas["total"]["sw_products"];
?>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="items_list">
        	<table border="1">
        	<?php 
        		if(!empty($report)){
        			echo "<tr><td colspan='12' align='center' style='font-size:18px'><b>".$year."年".$month."月入驻企业统计汇总报表</b></td></tr>";
        		}
        	?>
            	<tr>
                    <th class="th" rowspan="2">领军人才数据指标</th>
		 			<th class="th" colspan="2">产值</th>
		 			<th class="th" colspan="2">总收入</th>
		 			<th class="th" colspan="2">利税总和</th>
		 			<th class="th" colspan="2">利润总额</th>
		 			<th class="th" colspan="3">科技产出</th>
                </tr>
                <tr>
		 			<th class="lth">累计（万元）</th>
		 			<th>同比（%）</th>
		 			<th class="lth">累计（万元）</th>
		 			<th>同比（%）</th>
		 			<th class="lth">累计（万元）</th>
		 			<th>同比（%）</th>
		 			<th class="lth">累计（万元）</th>
		 			<th>同比（%）</th>
		 			<th class="lth">专利数（件）</th>
		 			<th >高新产品（件）</th>
		 			<th class="rth">软件产品（件）</th>
		 		</tr>
		 		<tr>
		 			<td class="lth">入驻企业合计</td>
		 			<td class="lth"><?php echo $str->formatquantity($total_prospect);?></td>
		 			<td>
		 			<?php 
		 				if(empty($last_t_prospect) || $last_t_prospect==0){
		 					if(!empty($total_prospect) && $total_prospect !=0){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
		 				}else{
		 					if(!empty($total_prospect) && $total_prospect !=0){
		 						$data = ($total_prospect-$last_t_prospect)/$last_t_prospect*100;
		 						echo  $str->setIntPercent($data);
		 					}else{
		 						echo "-100";
		 					}
		 				}
		 			?>
		 			</td>
		 			<td class="lth"><?php echo $str->formatquantity($total_income);?></td>
		 			<td>
		 			<?php 
			 			if(empty($last_t_income) || $last_t_income==0){
			 				if(!empty($total_income) && $total_income!=0){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
			 			}else{
			 				if(!empty($total_income) && $total_income!=0){
				 				$data = ($total_income-$last_t_income)/$last_t_income*100;
				 				echo  $str->setIntPercent($data);
			 				}else{
			 					echo "-100";
			 				}
			 			}
		 			?>
		 			</td>
		 			<td class="lth"><?php echo $str->formatquantity($total_tax);?></td>
		 			<td>
		 			<?php 
		 				if(empty($last_t_tax) || $last_t_tax==0){
		 					if(!empty($total_tax) && $total_tax !=0){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
		 				}else{
		 					if(!empty($total_tax) && $total_tax !=0){
			 					$data =($total_tax-$last_t_tax)/$last_t_tax*100;
			 					echo  $str->setIntPercent($data);
		 					}else{
		 						echo "-100";
		 					}
		 				}
		 				
		 			?>
		 			</td>
		 			<td class="lth"><?php echo $str->formatquantity($total_profit);?></td>
		 			<td>
		 			<?php 
		 				if(empty($last_t_profit) || $last_t_profit==0){
		 					if(!empty($total_profit)&& $total_profit !=0){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
		 				}else{
		 					if(!empty($total_profit)&& $total_profit !=0 ){
			 					$data = ($total_profit-$last_t_profit)/$last_t_profit*100;
			 					echo  $str->setIntPercent($data);
		 					}else{
		 						echo "-100";
		 					}
		 				}
		 			?>
		 			</td>
		 			<td class="lth"><?php echo $str->formatquantity($total_patents);?></td>
		 			<td><?php echo $str->formatquantity($total_ht_products);?></td>
		 			<td class="rth"><?php echo $str->formatquantity($total_sw_products);?></td>
		 		</tr>
		 		<?php 
		 			$i = 0;
		 			$aprt = "";
		 			$datacount = count($totaldatas);
		 			foreach($totaldatas  as $key => $value){
		 			if($key != "total"){
		 				if($i == 0){
		 					$aprt = "其中：";
		 				}
		 		?>
		 		<tr>
		 			<td class="lth"><?php echo $str->formatquantity($aprt.$totaldatas[$i]["cvalue"]);?></td>
		 			<td class="lth"><?php echo $str->formatquantity($totaldatas[$i]["prospect"]);?></td>
		 			<td>
		 			<?php 
		 				if(empty($last_totaldatas[$i]["prospect"]) || $last_totaldatas[$i]["prospect"]==0){
		 					if(!empty($totaldatas[$i]["prospect"]) && $totaldatas[$i]["prospect"]!=0){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
		 				}else{
		 					debug(empty($last_totaldatas[$i]["prospect"]));
		 					if(!empty($totaldatas[$i]["prospect"])&& $totaldatas[$i]["prospect"]!=0){
			 					$data = ($totaldatas[$i]["prospect"]-$last_totaldatas[$i]["prospect"])/$last_totaldatas[$i]["prospect"]*100;
			 					echo  $str->setIntPercent($data);
		 					}else{
		 						echo "-100";
		 					}
		 				}
		 				
		 			?>
		 			</td>
		 			<td class="lth"><?php echo $str->formatquantity($totaldatas[$i]["income"]);?></td>
		 			<td>
		 			<?php 
			 			if(empty($last_totaldatas[$i]["income"]) || $last_totaldatas[$i]["income"]==0){
			 				if(!empty($totaldatas[$i]["income"])&& $totaldatas[$i]["income"]!=0 ){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
			 			}else{
			 				if(!empty($totaldatas[$i]["income"])&& $totaldatas[$i]["income"]!=0){
				 				$data = ($totaldatas[$i]["income"]-$last_totaldatas[$i]["income"])/$last_totaldatas[$i]["income"]*100;
				 				echo  $str->setIntPercent($data);
			 				}else{
			 					echo "-100";
			 				}
			 			}
		 			?>
		 			</td>
		 			<td class="lth"><?php echo $str->formatquantity($totaldatas[$i]["tax"]);?></td>
		 			<td>
		 			<?php 
		 				if(empty($last_totaldatas[$i]["tax"]) || $last_totaldatas[$i]["tax"]==0){
		 					if(!empty($totaldatas[$i]["tax"])&& $totaldatas[$i]["tax"] !=0){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
		 				}else{
		 					if(!empty($totaldatas[$i]["tax"])&& $totaldatas[$i]["tax"] !=0){
			 					$data = ($totaldatas[$i]["tax"]-$last_totaldatas[$i]["tax"])/$last_totaldatas[$i]["tax"]*100;
			 					echo  $str->setIntPercent($data);
		 					}else{
		 						echo "-100";
		 					}
		 				}
		 				
		 			?>
		 			</td>
		 			<td class="lth"><?php echo $str->formatquantity($totaldatas[$i]["profit"]);?></td>
		 			<td>
		 			<?php 
		 				if(empty($last_totaldatas[$i]["profit"]) || $last_totaldatas[$i]["profit"]==0){
		 					if(!empty($totaldatas[$i]["profit"])&&$totaldatas[$i]["profit"] !=0){
		 						echo "100";
		 					}else{
		 						echo  "-";
		 					}
		 				}else{
		 					if(!empty($totaldatas[$i]["profit"])&&$totaldatas[$i]["profit"] !=0){
			 					$data = ($totaldatas[$i]["profit"]-$last_totaldatas[$i]["profit"])/$last_totaldatas[$i]["profit"]*100;
			 					echo  $str->setIntPercent($data);
		 					}else{
		 						echo "-100";
		 					}
		 				}
		 			?>
		 			</td>
		 			<?php 
		 				$style = "";
		 				if($i == $datacount-1){
		 					$style = "style='border-bottom:2px solid'";
		 				}
		 			?>
		 			<td class="lth" rowspan="2" <?php echo $style;?>><?php echo $str->formatquantity($totaldatas[$i]["patents"]);?></td>
		 			<td rowspan="2"><?php echo $str->formatquantity($totaldatas[$i]["ht_products"]);?></td>
		 			<td rowspan="2" class="rth"><?php echo $str->formatquantity($totaldatas[$i]["sw_products"]);?></td>
		 		</tr>
		 		<tr>
		 			<td class="lth">占比（%）</td>
		 			<td class="lth" colspan="2"><?php echo $total_prospect == 0 ? 0 :  $str->setIntPercent($totaldatas[$i]["prospect"]/$total_prospect*100);?></td>
		 			<td class="lth" colspan="2"><?php echo $total_income == 0 ? 0 : $str->setIntPercent($totaldatas[$i]["income"]/$total_income*100);?></td>
		 			<td class="lth" colspan="2"><?php echo $total_tax == 0 ? 0 : $str->setIntPercent($totaldatas[$i]["tax"]/$total_tax*100);?></td>
		 			<td class="lth" colspan="2"><?php echo $total_profit == 0 ? 0 : $str->setIntPercent($totaldatas[$i]["profit"]/$total_profit*100);?></td>
		 		</tr>
		 		<?php 
		 			$aprt = "";
		 			$i++;
		 			}
		 		}?>
            </table>
		</div>
    </div>
</div>
<?php if(empty($report)){?>
<script>
var webpath=$("#getpath").attr('href');
var urlpath=webpath+"reports/totaldatareport/?seach=all";
$(document).ready(function(){
	$("#ddlgroup").change(function(){
		searchproject();
		});
	$("#ddlyear").change(function() {  
		searchproject();
	});
	$("#ddlmonth").change(function(){
		searchproject();
	});
});
function searchproject()
{
	var group=$("#ddlgroup").val();
	var year = $("#ddlyear").val();
	var month = $("#ddlmonth").val();
	
	if(group=="" && year=="" && month=="" && status=="" && capital==""){
		window.location.href=urlpath;
	}else{
		if(group!=""){
			urlpath+="&group="+group;
			}
		if(year.trim() != ""){
			urlpath+="&year="+year.trim();
		}
		if(month.trim() != ""){
			urlpath+="&month="+month.trim();
		}
		window.location.href=urlpath;
	}
	return false;
}
</script>
<?php }?>